﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using AspNetCs.IDAL;
using AspNetCs.DALFactory;
namespace AspNetCs.Bll
{
    public class Pager
    {
        private IPager PageBind = Conn.CreatePager();

        private Control obj;
        private string tablename = "";
        private string recolumns = " * ";
        private string orderfld = "";
        private int pageIndex = 1;
        private int pageSize = 10;
        private string orderType = "";
        private string whereStr = "";
        private string ident = "";

        /// <summary>
        /// 绑定的控件
        /// </summary>
        public Control Obj { get { return obj; } set { obj = value; } }
        /// <summary>
        /// 查询的表名
        /// </summary>
        public string TableName { get { return tablename; } set { tablename = value; } }
        /// <summary>
        /// 需要返回的列,默认=*
        /// </summary>
        public string Recolumns { get { return recolumns; } set { recolumns = value; } }

        /// <summary>
        /// 排序字段
        /// </summary>
        public string Orderfld { get { return orderfld; } set { orderfld = value; } }

        /// <summary>
        /// 当前页
        /// </summary>
        public int PageIndex { get { return pageIndex; } set { pageIndex = value; } }
        /// <summary>
        /// 每页条数
        /// </summary>
        public int PageSize { get { return pageSize; } set { pageSize = value; } }
        /// <summary>
        /// 排序方式; 非 asc值则降序
        /// </summary>
        public string OrderType { get { return orderType; } set { orderType = value; } }
        /// <summary>
        /// Where 条件
        /// </summary>
        public string WhereStr { get { return whereStr; } set { whereStr = value; } }
        /// <summary>
        /// 表中的唯一键值的字段名
        /// </summary>
        public string Ident { get { return ident; } set { ident = value; } }



        #region IPager 成员


        public void ControlBind()
        {
            PageBind.ControlBind(this.Obj, this.tablename, this.recolumns, this.orderfld, this.pageIndex, this.pageSize, this.orderType, this.whereStr, this.ident);
        }
        public int recordcount()
        {
            return PageBind.ReCount(this.Obj, this.tablename, this.recolumns, this.orderfld, this.pageIndex, this.pageSize, this.orderType, this.whereStr, this.ident);
        }


        #endregion
    }
}
